package 
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.JPEGEncoderOptions;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.geom.Rectangle;
	import flash.net.FileReference;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.utils.ByteArray;
	import net.hires.debug.Stats;
	import net.WebClient;
	
	/**
	 * ...
	 * @author Ivan
	 */
	public class Main extends Sprite 
	{
		private var luna:Luna;
		
		public function Main():void 
		{	
		
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			
			luna = new Luna(stage, new Rectangle(0, 0, 640, 480));
			onLoadMap(null);
			var stats:Stats = new Stats();
			addChild(stats);
			stats.x = 640;
		}
		
		private function onLoadMap(data:ByteArray):void 
		{
			var map:Map = new Map();
			map.read(data);
			luna.setMap(map);
			addEventListener(Event.ENTER_FRAME, onUpdate);
		}
		
		private function onUpdate(e:Event):void 
		{
			luna.update();
			luna.draw();
		}
	}
	
}